class MyClass:

    def __new__(cls, *args, **kwargs):
        print('__new__')
        return super(MyClass, cls).__new__(cls)

    def __init__(self, name):
        print('__init__')

    def __del__(self):
        # 对象被释放的时候会调用，但是不会百分百调用
        pass


# my_class = MyClass('zhangsan')

# 单例模式
class Singleton:
    __instance = None

    def __new__(cls, *args, **kwargs):
        if Singleton.__instance is None:
            Singleton.__instance = super().__new__(cls)
        return Singleton.__instance

    def __init__(self):
        pass


single = Singleton()
print(id(single))
single2 = Singleton()
print(id(single2))
